﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

using Lucene.Net.Search;

namespace XMK.Utils
{
    public class LuceneSort
    {
        public LuceneSort()
        {
            LuSort = new Sort();
        }

        public Sort LuSort
        {
            get;
            private set;
        }

        private List<SortField> SortFieldList = new List<SortField>();

        public LuceneSort AddAsc(string fieldName, LuceneSortType t)
        {
            SortField field = new SortField(fieldName, (int)t);
            SortFieldList.Add(field);
            LuSort = new Sort(SortFieldList.ToArray());
            return this;
        }

        public LuceneSort AddDesc(string fieldName, LuceneSortType t)
        {
            SortField field = new SortField(fieldName, (int)t, true);
            SortFieldList.Add(field);
            LuSort = new Sort(SortFieldList.ToArray());
            return this;
        }

    }

    public enum LuceneSortType
    {
        BYTE = 10,
        CUSTOM = 9,
        DOC = 1,
        DOUBLE = 7,
        FLOAT = 5,
        INT = 4,
        LONG = 6,
        SCORE = 0,
        SHORT = 8,
        STRING = 3,
        STRING_VAL = 11
    }
}       